package com.wondersgroup.app.appointment.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wondersgroup.core.frame.BaseController;
import com.wondersgroup.core.frame.CommonStatusResult;
import com.wondersgroup.core.resultmap.DTOProduct;
import com.wondersgroup.core.service.ProductInfoService;
import com.wondersgroup.core.util.ErrorMessageConstant;

@Controller
@RequestMapping("/productInfo")
public class ProductInfoController extends BaseController{
	@Autowired
	private ProductInfoService productInfoService;
	@RequestMapping(value="/queryProductInfoByBarcode", method = RequestMethod.POST)
	@ResponseBody
	public CommonStatusResult queryProduct(
			@RequestParam(required=true,value="barcode") String barcode){
		if(!barcode.equals("6948195800309")&&!barcode.equals("6901209302220")&&!barcode.equals("6925303710156")){
			return CommonStatusResult.fail(ErrorMessageConstant.CODE_FAIL, null);
		}
		DTOProduct dtoProduct=productInfoService.findProductByBarcode(barcode);
		
		return CommonStatusResult.success(ErrorMessageConstant.CODE_SUCCESS, dtoProduct);
		}
}
